-- region *.lua
-- Date
-- 此文件由[BabeLua]插件自动生成
TipBaseDlg = Dialog:DeriveClass("TipBaseDlg", "TipBaseDlg.prefab", 99,
{
    _DescriptText;
    _DescriptLabel;
    _TitleLabel;
} )

function TipBaseDlg:OnInit(args)
    local closeBtn = self:GetYButton("CloseButton");
    closeBtn:SetClickHandler(self, self.Close);
    self:SetClickHitHandler(TipBaseDlg.ClickHitHandler);
    self._DescriptLabel = self:GetYLabel("DecriptLabel");
    self._TitleLabel = self:GetYLabel("TitleLabel")
    self._DescriptText = args.Des;
    self._TitleLabel.text = args.Tilte;
    local fitter = self._DescriptLabel:GetComponent(UI.ContentSizeFitter);
    fitter.verticalFit = UI.ContentSizeFitter.FitMode.PreferredSize;
    self._DescriptLabel.text = self._DescriptText;
    local height = self._DescriptLabel.preferredHeight;
    local rtf = self:GetWindow().Root:GetComponent(RectTransform)
    rtf.sizeDelta = Vector2(rtf.sizeDelta.x, math.max(200, height + 100));
end

function TipBaseDlg:ClickHitHandler(hitObj, hitMe)
    if not hitMe then self:Close(); end
end


function TipBaseDlg.CreateTip(descriptText, title)
    local tipBaseDlg = DlgMgr:FetchDlg(TipBaseDlg, { Des = descriptText, Tilte = title });
    return tipBaseDlg;
end

function TipBaseDlg:SetAlignment(ali)
    self._DescriptLabel.alignment = ali;
end
-- endregion
